import './public-path';
import './index.css';
import App from './App';
import React from 'react';
import ReactDOM from 'react-dom/client'; // react18
// import ReactDOM from 'react-dom'; // react16-17
// import reportWebVitals from './reportWebVitals';
// import { BrowserRouter } from 'react-router-dom'; // 路由器

const containerElement = document.getElementById('yourContainer2')
const root = ReactDOM.createRoot(containerElement);
function render(props) {
    const { container } = props
    root.render(
        // <BrowserRouter forceRefresh={true}>
        //     <App />
        // </BrowserRouter>,
        <App />,
        container ? container.querySelector('#yourContainer2') : document.getElementById('#yourContainer2')
    );
}
if (!window.__POWERED_BY_QIANKUN__) {
    render({});
}


export async function mount(props) {
    console.log('[react18] props from main framework', props);
    render(props);
}

export async function unmount(props) {
    const { container } = props;
    // root.unmount()  // react17
    // ReactDOM.unmountComponentAtNode(root); // react17
    root.unmount(container ? container.querySelector('#yourContainer2') : document.querySelector('#yourContainer2'));
}

export async function update() {
    // 更新微应用
}